package com.meet.dao;

import com.meet.util.JDBCutil;
import com.meet.vo.MeetingVo;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class RoomDaoImpl implements RoomDao{
    @Override
    public List<MeetingVo> getAllRoomTimeByRoomId(int roomid) throws SQLException {
        List<MeetingVo> lists=new ArrayList<MeetingVo>();
        Connection connection = null;
        connection = JDBCutil.getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement("select m.* ,r_name from meeting m, boardroom r where m.r_id=r.id and r.id=1");

        ResultSet resultSet = preparedStatement.executeQuery();
        while(resultSet.next()){
            MeetingVo meeting = new MeetingVo();
            meeting.setId(resultSet.getInt("id"));
            meeting.setmName(resultSet.getString("m_name"));
            meeting.setrName(resultSet.getString("r_name"));
            meeting.settStart(resultSet.getTimestamp("t_start"));
            meeting.settEnd(resultSet.getTimestamp("t_end"));
            meeting.setwName(resultSet.getString("w_id"));
            meeting.settReserve(resultSet.getTimestamp("t_reserve"));
            meeting.setrId(resultSet.getInt("r_id"));
//            meeting.setContent(resultSet.getString("content"));

            lists.add(meeting);
        }

        resultSet.close();
        JDBCutil.closeConnection();
        return lists;
    }
}
